package com.sc.nft.enums;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.enums
 * @Project：sc_metago
 * @name：MemberEquityTemplateeceiveCycleEnum
 * @Date：2024/4/3 14:58
 * @Filename：MemberEquityTemplateeceiveCycleEnum
 */
@AllArgsConstructor
@Getter
public enum MemberEquityTemplateeceiveCycleEnum {
    FULL("FULL", "整个周期"),
    PRE_DAY("PRE_DAY", "每天"),
    PRE_WEEk("PRE_WEEk", "每周"),
    PRE_MONTH("PRE_MONTH", "每月"),
    PRE_YEAR("PRE_YEAR", "每年"),
    ;

    @EnumValue
    private String code;

    private String desc;

    public Map<String, Date> getTimeMap(Date now) {
        Date startTime = null;
        Date endTime = null;
        if (MemberEquityTemplateeceiveCycleEnum.PRE_DAY.equals(this)) {
            // 每天
            startTime = DateUtil.beginOfDay(now);
            endTime = DateUtil.endOfDay(now);

        } else if (MemberEquityTemplateeceiveCycleEnum.PRE_WEEk.equals(this)) {
            // 每周
            startTime = DateUtil.beginOfWeek(now);
            endTime = DateUtil.endOfWeek(now);
        } else if (MemberEquityTemplateeceiveCycleEnum.PRE_MONTH.equals(this)) {
            // 每月
            startTime = DateUtil.beginOfMonth(now);
            endTime = DateUtil.endOfMonth(now);
        } else if (MemberEquityTemplateeceiveCycleEnum.PRE_YEAR.equals(this)) {
            // 每年
            startTime = DateUtil.beginOfYear(now);
            endTime = DateUtil.endOfYear(now);
        }else {
            return null;
        }
        Map<String, Date> map = Maps.newHashMap();
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        return map;
    }
}
